import numpy as np
import pandas as pd


def main():
    '''
    0    1
    1    2
    2    3
    3    4
    dtype: int64
    '''
    s1 = pd.Series([1, 2, 3, 4])
    print(s1)
    # [1 2 3 4]
    print(s1.values)
    # RangeIndex(start=0, stop=4, step=1)
    print(s1.index)


    '''
    0    0
    1    1
    2    2
    3    3
    4    4
    5    5
    6    6
    7    7
    8    8
    9    9
    dtype: int64
    '''
    s2 = pd.Series(np.arange(10))
    print(s2)

    '''
    a    1
    b    2
    c    3
    dtype: int64
    '''
    s3 = pd.Series({'a':1, 'b':2, 'c':3})
    print(s3)

    '''
    a    1
    b    2
    c    3
    dtype: int64
    '''
    s4 = pd.Series([1,2,3], index=['a','b','c'])
    print(s4['a'], s4[0]) # 等价，都是1
    '''
    c    3
    dtype: int64
    得到的类型是pandas类型
    '''
    print(s4[s4 > 2])

    # 转成map类型
    s4.to_dict()

    # 判断哪些为空
    pd.isnull(s4)
    # 判断哪些不为空
    pd.notnull(s4)

    s4.name = 'xxx'
    s4.index.name = 'yyy'
    print(s4)

if __name__ == '__main__':
    main()
